package com.hospital.xiaochengxiu.yan.controller;

import com.alibaba.fastjson.JSON;
import com.hospital.xiaochengxiu.yan.entity.Consumeinfo;
import com.hospital.xiaochengxiu.yan.entity.DepartmentQueue;
import com.hospital.xiaochengxiu.yan.entity.DoctorMedicine;
import com.hospital.xiaochengxiu.yan.service.ConsumeinfoService;
import com.hospital.xiaochengxiu.yan.service.DepartmentQueueService;
import com.hospital.xiaochengxiu.yan.service.DoctorMedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
public class ConsumeinfoController {

    @Autowired
    private ConsumeinfoService consumeinfoService;
    @Autowired
    private DepartmentQueueService departmentQueueService;
    @Autowired
    private DoctorMedicineService doctorMedicineService;
    /**
     * 根据传的卡号查询出缴费记录信息
     * @return
     */
    @GetMapping("/selectByCard/{cardNo}")
    public String selectByCard(@PathVariable String cardNo){
        if(cardNo==null || cardNo.equals("")){
            return null;
        }
        List<Consumeinfo> consumeinfos = consumeinfoService.selectByCardNo(cardNo);
        return JSON.toJSONString(consumeinfos);
    }

    /**
     *查询用户未缴费的ct记录
     * @return
     */
    @GetMapping("/selectCtRecord/{cardNo}")
    public String selectCtRecord( @PathVariable String cardNo){
        if(cardNo==null || cardNo.equals("")){
           return null;
        }
        List<DepartmentQueue> departmentQueues = departmentQueueService.selectDepartmentQueue(cardNo);
        return JSON.toJSONString(departmentQueues);
    }

    /**
     *查询用户未缴费的药单记录
     * @return
     */
    @GetMapping("/selectDrugRecord/{cardNo}")
    public String selectDrugRecord(@PathVariable String cardNo){
        if(cardNo==null || cardNo.equals("")){
            return null;
        }
        List<DoctorMedicine> doctorMedicines = doctorMedicineService.selectDoctorMedicineTwo(cardNo);
        return JSON.toJSONString(doctorMedicines);
    }

    /**
     * 查询该记录的总价
     * @param cardNo
     * @return
     */
    @GetMapping("/selectMoney/{cardNo}")
    public String selectMoney(@PathVariable String cardNo){
        return "";
    }

}
